#include "MyDlgCtrl.h"
#include <stdio.h>
MyDlgCtrl::MyDlgCtrl()
{
	 
}

void MyDlgCtrl::GetPrvSize(struct parameter inputData)
{	


	GetClientRect(inputData.hwndDlg,&rectDlgPrv);
	this->iClientWidth = rectDlgPrv.right - rectDlgPrv.left;
	this->iClientHeight = rectDlgPrv.bottom - rectDlgPrv.top;
	
	//*sprintf(str3,"str3 %d",(int)inputData.hwndDlg);
	//*MessageBox(NULL,(LPCTSTR)str3,NULL,MB_OK);
	//*inputData.hwndCtrl = GetDlgItem(inputData.hwndDlg,inputData.nIDDlgItem);
	GetWindowRect(GetDlgItem(inputData.hwndDlg,inputData.nIDDlgItem),&rectCtrl);
	MapWindowPoints(NULL,inputData.hwndDlg,(LPPOINT)&rectCtrl,2);
	//*sprintf(str4,"str4 %d",(int)inputData.hwndCtrl);
	//*MessageBox(NULL,(LPCTSTR)str4,NULL,MB_OK);

	//return inputData;

}
BOOL MyDlgCtrl::MoveCtrl(struct parameter inputData)
{

	int cxClient,cyClient,incrementX,incrementY,ix,iy,iwidth,iheight;

	cxClient = LOWORD(inputData.lParam);
	cyClient = HIWORD(inputData.lParam);

	incrementX = cxClient - iClientWidth;
	incrementY = cyClient - iClientHeight;
	//*inputData.hwndCtrl = GetDlgItem(inputData.hwndDlg,inputData.nIDDlgItem);
	//*sprintf(str2,"str2 %d",(int)inputData.hwndCtrl);
	//*	MessageBox(NULL,(LPCTSTR)str2,NULL,MB_OK);
	//*sprintf(str3,"str3 %d",(int)inputData.hwndDlg);
	//*MessageBox(NULL,(LPCTSTR)str3,NULL,MB_OK);
	switch(inputData.ctrlStatus)
	{
	case MOVEx:
		ix = rectCtrl.left + incrementX;
		iy = rectCtrl.top;
		iheight = rectCtrl.bottom - rectCtrl.top;
		iwidth = rectCtrl.right - rectCtrl.left;
		//*sprintf(str4,"str4 %d",(int)inputData.hwndCtrl);
		//*MessageBox(NULL,(LPCTSTR)str4,NULL,MB_OK);
		//*sprintf(str5,"STR5 %d _ %d _ %d _ %d",ix,iy,iwidth,iheight);
		//*MessageBox(NULL,(LPCTSTR)str5,NULL,MB_OK);
		MoveWindow(GetDlgItem(inputData.hwndDlg,inputData.nIDDlgItem),ix,iy,iwidth,iheight,TRUE);
		break;
	case MOVEy:
		ix = rectCtrl.left;
		iy = rectCtrl.top + incrementY;
		iwidth = rectCtrl.right - rectCtrl.left;
		iheight = rectCtrl.bottom - rectCtrl.top;
		MoveWindow(GetDlgItem(inputData.hwndDlg,inputData.nIDDlgItem),ix,iy,iwidth,iheight,TRUE);
		break;
	case MOVExy:
		ix = rectCtrl.left + incrementX;
		iy = rectCtrl.top + incrementY;
		iwidth = rectCtrl.right - rectCtrl.left;
		iheight = rectCtrl.bottom - rectCtrl.top;
		MoveWindow(GetDlgItem(inputData.hwndDlg,inputData.nIDDlgItem),ix,iy,iwidth,iheight,TRUE);
		break;
	case LARGEx:
		ix = rectCtrl.left;
		iy = rectCtrl.top;
		iwidth = rectCtrl.right - rectCtrl.left + incrementX;
		iheight = rectCtrl.bottom - rectCtrl.top;
		MoveWindow(GetDlgItem(inputData.hwndDlg,inputData.nIDDlgItem),ix,iy,iwidth,iheight,TRUE);
		break;
	case LARGEy:
		ix = rectCtrl.left;
		iy = rectCtrl.top;
		iwidth = rectCtrl.right - rectCtrl.left;
		iheight = rectCtrl.bottom - rectCtrl.top + incrementY;
		MoveWindow(GetDlgItem(inputData.hwndDlg,inputData.nIDDlgItem),ix,iy,iwidth,iheight,TRUE);
		break;
	case LARGExy:
		ix = rectCtrl.left;
		iy = rectCtrl.top;
		iwidth = rectCtrl.right - rectCtrl.left + incrementX;
		iheight = rectCtrl.bottom - rectCtrl.top + incrementY;
		MoveWindow(GetDlgItem(inputData.hwndDlg,inputData.nIDDlgItem),ix,iy,iwidth,iheight,TRUE); 
		break;
	default:
		break;
	}
	return TRUE;
}

